<template>
  <div>
    <div
      style="font-size: 16px;font-weight: 500;color: #1D2129;margin-bottom: 16px;"
    >
      体校类别
    </div>

    <div style="display: flex; ">
      <img
        src="@/assets/img/Frame@2x.png"
        alt=""
        style="width: 32px;height: 32px; margin-right: 16px;18px;margin-top: 5px"
      />
      <div>
        <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
        <div style="font-size: 12px;">全国体育传统项目学校数量/所</div>
      </div>
    </div>
    <div
      style="height: 40px;width: 100%;background: #F9F9F9;line-height: 40px;margin-top: 16px;"
    >
      <div style="font-size: 12px;color: #165DFF;margin-left: 20px;">
        学校所属重点学校类型
      </div>
    </div>
    <div ref="chart" style="height:160px;width: 100%;"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "SchoolType",
  data() {
    return {
      chartInstance: null,
      chartData: {
        title: {
          text: "全国体校数量/所"
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
          orient: "vertical",
          left: "left",
          data: [
            "省级重点(示范校)",
            "地市级重点(示范校)",
            "区县级重点(示范校)",
            "普通学校"
          ]
        },
        series: [
          {
            name: "体校数量",
            type: "pie",
            radius: ["50%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "30",
                fontWeight: "bold"
              }
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 34201, name: "省级重点(示范校)", color: "#3398DB" },
              { value: 34201, name: "地市级重点(示范校)", color: "#578DD5" },
              { value: 34201, name: "区县级重点(示范校)", color: "#80B8F1" },
              { value: 34201, name: "普通学校", color: "#FF6666" }
            ]
          }
        ]
      }
    };
  },
  mounted() {
    this.initChart();
  },
  beforeDestroy() {
    if (this.chartInstance) {
      this.chartInstance.dispose();
    }
  },
  methods: {
    initChart() {
      this.chartInstance = echarts.init(this.$refs.chart);
      this.chartInstance.setOption(this.chartData);
    }
  }
};
</script>

<style scoped></style>
